package com.atguigu.myrule;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MySelfRule {
    //ribbon默认负载均衡策略是：轮询，这里自定义修改，设置为另一个负载均衡策略：随机
    //通过多次访问http:80//localhost/consumer/payment/get/1，发现随机落在8001和8002服务器
    @Bean
    public IRule myRule(){
       return new RandomRule();//定义为随机
    }
}
